<?php 
class CategoryController extends Zend_Controller_Action
{
	public function indexAction()
	{
		$define = Zend_Registry::get('define');
		$req = $this->getRequest();
		$page = $req->getParam('page', 1);
		$categoryAlias = $req->getParam('category_alias');
		$categoryId = intval(My_Model_Category::getInstance()->getCategoryByAlias($categoryAlias));
		if( $categoryId > 0 ) {
			// OK
			$where = 'tours.active = 1 AND categories_tours.category_id = '.$categoryId;
			$tours = My_Model_Tour::getInstance()->getTourList($page, $define['frontend']['tour_list_limit'], $where);
			$amount = My_Model_Tour::getInstance()->getAmount($where);
			$this->view->items = $tours;
			$this->view->amount = $amount;
			$this->view->categories = My_Model_Category::getInstance()->getAllCategories();
			print_r($tours); 
		} else {
			// Redirect to 404
			//$this->_redirect('/error-404/', array('code' => 404 ));
		}
		
		$this->_helper->viewRenderer->setNoRender();
	}
}
?>
